<?php
require_once 'model/Model.php';
class ModelComment extends Model{
    
    function __construct() {
        parent::connection();
    }
    
    //retourne un tableau mysql_fetch_array 
    function selectAll($id){
        $query = "select * from sb_comment where COMMENT_ID_EVENT=$id ORDER BY COMMENT_DATE DESC";
        $result = mysql_query($query);
        return $result;        
    }
    
    function insert($id, $pseudo, $content, $note){
        $query = "insert into sb_comment (COMMENT_USER, COMMENT_CONTENT, COMMENT_NOTE, COMMENT_ID_EVENT, COMMENT_DATE) values ('$pseudo', '$content', $note, $id, now())";
        mysql_query($query);
    }
    
    function delete($id){
        $query = "delete from sb_comment where COMMENT_ID=$id";
        mysql_query($query);
    }
    
}
?>
